import {useMemo, useState} from 'react';

const Demo = () => {
    const [number, setNumber] = useState(0);
    const newLog = useMemo(() => {
        const log = () => {
            console.log(number);
        }
        return log;
    }, [])

    return (
        <div className="border">
            <p className="title">Demo--useMemo--3</p>

            <p>count: {number}</p>
            <button onClick={() => {newLog()}}>打印</button>
            <button onClick={() => {setNumber(number + 1)}}>add</button>
        </div>
    )
}

export default Demo;